#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, q;
struct bit {
  int t[N];
  void add(int x, int v) {
    for (int i = x; i <= n; i += i & -i) t[i] += v;
  }
  int qry(int x) {
    int res = 0;
    for (int i = x; i; i -= i & -i) res += t[i];
    return res;
  }
} t1, t2;
struct edge {
  int to, nxt;
} e[N << 1];
int head[N], cnt;
void add(int u, int v) {
  e[++cnt] = (edge){v, head[u]};
  head[u] = cnt;
}
set<int> s[N];
set<int>::iterator it;
int dfn[N], siz[N], id[N], tim;
void dfs(int u, int fa) {
  dfn[u] = ++tim, id[tim] = u, siz[u] = 1;
  for (int i = head[u], v; i; i = e[i].nxt) {
    v = e[i].to;
    if (v == fa) continue;
    dfs(v, u);
    siz[u] += siz[v];
  }
}
int main() {
  cin >> n >> q;
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    add(u, v), add(v, u);
  }
  dfs(1, 0);
  for (int i = 1, opt, u, c; i <= q; i++) {
    cin >> opt >> u;
    if (opt == 1) {
      cin >> c;
      it = s[c].lower_bound(dfn[u]);
      if (it != s[c].begin() &&
          dfn[id[*prev(it)]] + siz[id[*prev(it)]] >= dfn[u] + siz[u])
        continue;
      while (it != s[c].end() && *it < dfn[u] + siz[u])
        t1.add(*it, -1), t1.add(*it + siz[id[*it]], 1),
            t2.add(*it, -siz[id[*it]]), s[c].erase(it++);
      s[c].insert(dfn[u]), t1.add(dfn[u], 1), t1.add(dfn[u] + siz[u], -1),
          t2.add(dfn[u], siz[u]);
    } else
      printf("%d\n", siz[u] * t1.qry(dfn[u]) + t2.qry(dfn[u] + siz[u] - 1) -
                         t2.qry(dfn[u]));
  }
  return 0;
}
